package models

import "time"

/**
 * @Author SSWANG
 * @Description //TODO 帖子Post结构体
 * @Date 15:32 2022/10/28
 **/

// 内存对齐概念 字段类型相同的对齐 缩小变量所占内存大小
type Post struct {
	PostID      uint64    `gorm:"type:bigint(20);column:post_id;not null" json:"post_id,string"`
	AuthorId    uint64    `gorm:"type:bigint(20);column:author_id;not null" json:"author_id"`
	CommunityID uint64    `gorm:"type:bigint(20);column:community_id;not null" json:"community_id" binding:"required"`
	Status      int32     `gorm:"type:tinyint(4);column:status;not null" json:"status"`
	Title       string    `gorm:"type:varchar(128);column:title;not null" json:"title" binding:"required"`
	Content     string    `gorm:"type:varchar(8192);column:content;not null" json:"content" binding:"required"`
	CreateTime  time.Time `gorm:"type:timestamp;column:create_time;null" json:"-"`
}

// GORM: TableName 会将 Post 的表名重写为 `post`
func (Post) TableName() string {
	return "post"
}

/**
 * @Author SSWANG
 * @Description //TODO 帖子返回的详情结构体
 * @Date 19:48 2022/10/28
 **/
type ApiPostDetail struct {
	*Post                               // 嵌入帖子结构体
	*CommunityDetail `json:"community"` // 嵌入社区信息
	AuthorName       string             `json:"author_name"`
	VoteNum          int64              `json:"vote_num"`
	//CommunityName string `json:"community_name"`
}
